
local M = class("PokerType")


M.s_types = {}
M.s_types[1] = {min = 0, max = 1, kind = 10,  val = "Royal Flush", zh = "皇家同花顺"}
M.s_types[2] = {min = 1, max = 10, kind = 9,  val = "Straight Flush", zh = "同花顺"}
M.s_types[3] = {min = 11, max = 166, kind = 8, val = "Four of a Kind", zh = "四条"}
M.s_types[4] = {min = 167, max = 322, kind = 7, val = "Full Houses", zh = "葫芦"}
M.s_types[5] = {min = 323, max = 1599, kind = 6, val = "Flush", zh = "同花"}
M.s_types[6] = {min = 1600, max = 1609, kind = 5, val = "Straight", zh = "顺子"}
M.s_types[7] = {min = 1610, max = 2467, kind = 4, val = "Three of a Kind", zh = "三条"}
M.s_types[8] = {min = 2468, max = 3325, kind = 3, val = "Two Pair", zh = "两对"}
M.s_types[9] = {min = 3326, max = 6185, kind = 2, val = "One Pair", zh = "一对"}
M.s_types[10] = {min = 6186, max = 7462, kind = 1, val = "High Card", zh = "高牌"}

-- 根据牌结果取详细信息
function M:getDetail(rank)
    local data = nil
    rank = math.tointeger(rank) or 9999
    for _, v in ipairs(self.s_types) do
        if rank >= v.min and rank <= v.max then
            data = v
            break
        end
    end
    return data
end

function M:getKind(rank)
    local kind = 1
    local temp = self:getDetail(rank)
    if not temp then return kind end
    return temp["kind"]
end

function M:getType(rank)
    local kind = 1
    local temp = self:getDetail(rank)
    if not temp then return kind end

    return temp["val"]
end

return M